package org.watchrecords.pages.crime;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.watchrecords.dbo.Offender;
import org.watchrecords.managers.OffenderManager;
import org.watchrecords.pages.BasicPage;
import org.watchrecords.pages.MainPage;

import com.google.inject.Inject;

public class ViewOffenderPage extends BasicPage {
    @Inject private OffenderManager offenderManager;
    
    public ViewOffenderPage(PageParameters parameters) {
        super(parameters);
        Integer offenderId = getPageParameters() == null ? null : getPageParameters().getAsInteger("offenderId");
        Offender off = offenderId == null ? new Offender() : offenderManager.getOffender(offenderId);
        
        if(off == null) {
            setResponsePage(MainPage.class);
            return;
        }

        add(new Label("header", "View Offender: " + off.getFullName()));
        add(new Label("name", off.getFullName()));
        add(new Label("status", off.getStatus().toString()));
        add(new Label("unpaidFine", Integer.toString(off.getUnpaidFine())));
        add(new MultiLineLabel("description", off.getDescription()));
        add(new MultiLineLabel("possessions", off.getPossessions()));
    }
}
